package com.seari.tunnel.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.seari.tunnel.entity.CorridorIn;
import com.seari.tunnel.entity.CorridorInParam;
import com.seari.tunnel.entity.CorridorOut;
import com.seari.tunnel.entity.FeeConfig;
import com.seari.tunnel.entity.Namber;
import com.seari.tunnel.entity.PileNo;
import com.seari.tunnel.entity.PipelineInfo;
import com.seari.tunnel.entity.PipelineType;
import com.seari.tunnel.entity.Plies;
import com.seari.tunnel.entity.VisitApply;
import com.seari.tunnel.entity.WarehouseSection;
import com.seari.tunnel.mapper.CorridorInMapper;
import com.seari.tunnel.mapper.CorridorOutMapper;
import com.seari.tunnel.mapper.FeeConfigMapper;
import com.seari.tunnel.mapper.NamberMapper;
import com.seari.tunnel.mapper.PileNoMapper;
import com.seari.tunnel.mapper.PipelineInfoMapper;
import com.seari.tunnel.mapper.PipelineTypeMapper;
import com.seari.tunnel.mapper.PliesMapper;
import com.seari.tunnel.mapper.VisitApplyMapper;
import com.seari.tunnel.mapper.WarehouseSectionMapper;
import com.seari.tunnel.service.IProcedureService;

@Service(IProcedureService.SERVICE_NAME)
public class ProcedureServiceImpl implements IProcedureService{
	@Autowired
	CorridorInMapper corridorInMapper;
	@Autowired
	CorridorOutMapper corridorOutMapper;
	@Autowired
	PipelineTypeMapper pipelineTypeMapper;
	@Autowired
	WarehouseSectionMapper warehouseSectionMapper;
	@Autowired
	NamberMapper namberMapper;
	@Autowired
	PileNoMapper pileNoMapper;
	@Autowired
	PliesMapper pliesMapper;
	@Autowired
	PipelineInfoMapper pipelineInfoMapper;
	@Autowired
	FeeConfigMapper feeConfigMapper;
	@Autowired
	VisitApplyMapper visitApplyMapper;
	
	@Transactional
	@Override
	public void updatePipeline(CorridorIn corridorIn,PipelineInfo pipelineInfo)throws RuntimeException{
		corridorInMapper.updatePipeline(corridorIn);
		pipelineInfoMapper.addPipelineInfo(pipelineInfo);
		
	}

	@Override
	public void updateSigned(CorridorIn corridorIn) {
		corridorInMapper.updateSigned(corridorIn);
		
	}

	@Override
	public void updateExamine(CorridorIn corridorIn) {
		corridorInMapper.updateExamine(corridorIn);
		
	}

	@Override
	public List<CorridorIn> findProcedures() {
		
		return corridorInMapper.getProcedures();
	}

	@Transactional
	@Override
	public void updateAgreement(CorridorIn corridorIn, CorridorOut corridorOut)throws RuntimeException{
		corridorInMapper.updateAgreement(corridorIn);
		
		corridorOutMapper.createCorridorOut(corridorOut);
		
	}

	@Override
	public List<PipelineType> findPipelineTypes() {
		return pipelineTypeMapper.findPipelineTypes();
	}
	
	@Override
	public List<WarehouseSection> findWarehouseSections() {
		return warehouseSectionMapper.findWarehouseSections();
	}

	@Override
	public List<Namber> findNambers() {
		return namberMapper.findNambers();
	}

	@Override
	public List<PileNo> findSPileNos(int id) {
		
		return pileNoMapper.findSPileNos(id);
	}
	
	@Override
	public List<PileNo> findEPileNos(int id) {
		
		return pileNoMapper.findEPileNos(id);
	}

	@Override
	public List<Plies> findPlies(int id) {
		
		return pliesMapper.findPlies(id);
	}

	@Override
	public PipelineInfo findPipelineInfoById(int in_id) {
		
		return pipelineInfoMapper.findPipelineInfoById(in_id);
	}

	@Override
	public int pipelineInfoExist(int in_id) {
		
		return pipelineInfoMapper.pipelineInfoExist(in_id);
	}

	@Override
	public List<CorridorInParam> findProcedureParams() {
		
		return corridorInMapper.getProcedureParams();
	}

	@Override
	public String getAcceptApplicationById(int id) {
		
		return corridorInMapper.getAcceptApplicationById(id);
	}

	@Override
	public void updateProcedureFile(CorridorIn corridorIn) {
		corridorInMapper.updateProcedureFile(corridorIn);
		
	}
	
	@Override
	public void updateFeeConfig(FeeConfig feeConfig){
		feeConfigMapper.updateFeeConfig(feeConfig);
	}
	
	@Override
	public List<FeeConfig> findFeeConfig(){

		return feeConfigMapper.findFeeConfig();
		
	}

	@Override
	public List<VisitApply> findVisitApply() {
		
		return visitApplyMapper.findVisitApply();
	}

	@Override
	public void addVisitApply(VisitApply va) {
		visitApplyMapper.addVisitApply(va);
		
	}

	@Override
	public void updateVisitApply(VisitApply va) {
		visitApplyMapper.updateVisitApply(va);
		
	}

	@Override
	public void deleteVisitApply(int id) {
		visitApplyMapper.deleteVisitApply(id);
		
	}

}
